
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Spring MVC 中视图解析器的作用？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Spring MVC 中视图解析器的作用？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在Spring MVC中，视图解析器（View Resolver）的核心作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">视图解析器的核心作用是将控制器（Controller）处理请求后返回的逻辑视图名（如 "home"）映射到实际的视图文件（如 home.jsp），确定视图的类型和位置，并将模型数据传递给视图进行渲染，最终呈现给用户。</div>
          </div>
          <div class="card-source">来源: 1. 作用</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">视图解析器是如何将一个逻辑视图名（如 "home"）转换为一个具体的文件路径的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">视图解析器通过使用预先配置的信息（如前缀和后缀）来转换逻辑视图名。例如，如果配置了前缀为 "/WEB-INF/views/" 和后缀为 ".jsp"，逻辑视图名 "home" 就会被解析为实际路径 "/WEB-INF/views/home.jsp"。</div>
          </div>
          <div class="card-source">来源: 2. 工作机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">文档中提到的 `InternalResourceViewResolver` 主要用于解析哪种类型的视图？配置时通常需要设置哪两个属性？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`InternalResourceViewResolver` 主要用于解析 JSP 视图。配置时通常需要设置视图的前缀（prefix）和后缀（suffix），例如前缀为 "/WEB-INF/views/"，后缀为 ".jsp"。</div>
          </div>
          <div class="card-source">来源: 3. 常见的视图解析器</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">除了将逻辑视图名解析为物理视图，视图解析器在数据传递方面扮演了什么角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">视图解析器负责将模型数据（即 Controller 返回的数据）传递给视图进行渲染。它确保数据能够被正确地送达视图，以便在最终的页面上显示。</div>
          </div>
          <div class="card-source">来源: 1. 作用</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">文档中提到了哪两种用于解析不同模板引擎的常见视图解析器？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档中提到了两种常见的视图解析器：1. `InternalResourceViewResolver`，用于解析 JSP 视图。2. `ThymeleafViewResolver`，用于解析 Thymeleaf 模板。</div>
          </div>
          <div class="card-source">来源: 3. 常见的视图解析器</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Java配置中，如何为一个 `InternalResourceViewResolver` Bean 设置其前缀和后缀？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在Java配置中，可以通过调用 `InternalResourceViewResolver` 实例的 `setPrefix()` 和 `setSuffix()` 方法来设置前缀和后缀。例如：`resolver.setPrefix("/WEB-INF/views/");` 和 `resolver.setSuffix(".jsp");`。</div>
          </div>
          <div class="card-source">来源: 4. 配置示例</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
